package com.bwie.controller;

import com.bwie.pojo.Order;
import com.bwie.service.OrderService;
import com.bwie.utils.Result;
import com.bwie.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @projectName: server-day0718-pay
 * @package: com.bwie.controller
 * @className: OrderController
 * @author: 陈彤彤
 * @description: TODO
 * @date: 2025/7/23 15:34
 * @version: 1.0
 */
@RestController
@RequestMapping("/prod/order")
@Api(tags = "订单管理")
public class OrderController {

    @Autowired
    OrderService orderService;

    /**
    * @param orderVo:
    * @return Result
    * @author :陈彤彤
    * @description 分页查询订单信息
    * @date 2025/7/23 16:48
    */
    @ApiOperation(value = "分页查询订单信息")
    @PostMapping("/orderList")
    public Result orderList(@RequestBody OrderVo orderVo){
        return orderService.orderList(orderVo);
    }

    /**
    * @param ids:
    * @return Result
    * @author :陈彤彤
    * @description 批量删除订单信息
    * @date 2025/7/23 19:34
    */
    @ApiOperation(value = "批量删除订单信息")
    @PostMapping("/deleteOrderBath")
    public Result deleteOrderBath(@RequestBody List<Integer>ids){
        return orderService.deleteOrderBath(ids);
    }

    /**
    * @param userId:
    * @return void
    * @author :陈彤彤
    * @description 导出订单信息
    * @date 2025/7/23 20:50
    */
    @ApiOperation(value = "导出订单信息")
    @GetMapping("/exportOrder/{userId}")
    public void exportOrder(@PathVariable(name = "userId") Integer userId){
        orderService.exportOrder(userId);
    }

    /**
    * @param order:
    * @return Result
    * @author :陈彤彤
    * @description 添加订单信息
    * @date 2025/7/23 21:05
    */
    @ApiOperation(value = "添加订单信息")
    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody Order order){
        return orderService.addOrder(order);
    }

    /**
    * @param :
    * @return Result
    * @author :陈彤彤
    * @description 查询所有商品信息
    * @date 2025/7/23 21:34
    */
    @ApiOperation(value = "查询所有商品信息")
    @PostMapping("/selectProd")
    public Result selectProd(){
        return orderService.selectProd();
    }
}
